package com.luber.web.controller.backstage;

import java.util.List;

import com.luber.backstage.domain.EticketInvalidSeat;
import com.luber.backstage.domain.vo.EticketInvalidSeatVO;
import com.luber.backstage.service.IEticketInvalidSeatService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.luber.common.annotation.Log;
import com.luber.common.core.controller.BaseController;
import com.luber.common.core.domain.AjaxResult;
import com.luber.common.enums.BusinessType;
import com.luber.common.utils.poi.ExcelUtil;
import com.luber.common.core.page.TableDataInfo;

/**
 * 【无效座次】Controller
 *
 * @author luber
 * @date 2021-01-21
 */
@RestController
@RequestMapping("/backstage/invalidSeat")
public class EticketInvalidSeatController extends BaseController
{
    @Autowired
    private IEticketInvalidSeatService eticketInvalidSeatService;

    /**
     * 查询【无效座次】列表
     */
    @PreAuthorize("@ss.hasPermi('backstage:invalidSeat:list')")
    @GetMapping("/list")
    public TableDataInfo list(EticketInvalidSeat eticketInvalidSeat)
    {
        startPage();
        List<EticketInvalidSeatVO> list = eticketInvalidSeatService.selectEticketInvalidSeatList(eticketInvalidSeat);
        return getDataTable(list);
    }

    /**
     * 导出【无效座次】列表
     */
    @PreAuthorize("@ss.hasPermi('backstage:invalidSeat:export')")
    @Log(title = "【无效座次】", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(EticketInvalidSeat eticketInvalidSeat)
    {
        List<EticketInvalidSeatVO> list = eticketInvalidSeatService.selectEticketInvalidSeatList(eticketInvalidSeat);
        ExcelUtil<EticketInvalidSeatVO> util = new ExcelUtil<EticketInvalidSeatVO>(EticketInvalidSeatVO.class);
        return util.exportExcel(list, "seat");
    }

    /**
     * 获取【无效座次】详细信息
     */
    @PreAuthorize("@ss.hasPermi('backstage:invalidSeat:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(eticketInvalidSeatService.selectEticketInvalidSeatById(id));
    }

    /**
     * 新增【无效座次】
     */
    @PreAuthorize("@ss.hasPermi('backstage:invalidSeat:addList')")
    @Log(title = "【无效座次】", businessType = BusinessType.INSERT)
    @PostMapping("/addList")
    public AjaxResult addList(@RequestBody List<EticketInvalidSeat> list)
    {
        return toAjax(eticketInvalidSeatService.insertListEticketInvalidSeat(list));
    }

    /**
     * 新增【无效座次】
     */
    @PreAuthorize("@ss.hasPermi('backstage:invalidSeat:add')")
    @Log(title = "【无效座次】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EticketInvalidSeat eticketInvalidSeat)
    {
        return toAjax(eticketInvalidSeatService.insertEticketInvalidSeat(eticketInvalidSeat));
    }

    /**
     * 修改【无效座次】
     */
    @PreAuthorize("@ss.hasPermi('backstage:invalidSeat:edit')")
    @Log(title = "【无效座次】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EticketInvalidSeat eticketInvalidSeat)
    {
        return toAjax(eticketInvalidSeatService.updateEticketInvalidSeat(eticketInvalidSeat));
    }

    /**
     * 删除【无效座次】
     */
    @PreAuthorize("@ss.hasPermi('backstage:invalidSeat:remove')")
    @Log(title = "【无效座次】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(eticketInvalidSeatService.deleteEticketInvalidSeatByIds(ids));
    }
}
